﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using AnthStat.WPF.Applications;

namespace AnthStat.WPF.Presentation.Controls
{
    public class ProjectsSummaryView : Selector
    {
        static ProjectsSummaryView()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ProjectsSummaryView), new FrameworkPropertyMetadata(typeof(ProjectsSummaryView)));
        }

        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);

            FileScreenViewModel vm = this.DataContext as FileScreenViewModel;

            if (e.OriginalSource != null && vm != null)
            {
                Grid grdProject = e.OriginalSource as Grid;
                if (grdProject != null && grdProject.DataContext != null)
                {
                    ProjectInfoViewModel info = grdProject.DataContext as ProjectInfoViewModel;

                    vm.SetCurrentProject(info);
                }
            }
        }
    }
}
